<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input type="text"id="input1" value="50" />
		<button onclick="test1()">开启定时</button>
		<button onclick="test2()">关闭定时</button>
		<script type="text/javascript">
			var t
			function test1()
			{
				t=setInterval(change,input1.value)
			}
			function change()
			{
				var r=Math.floor(Math.random()*256)
				var g=Math.floor(Math.random()*256)
				var b=Math.floor(Math.random()*256)
				document.body.style.background="rgb("+r+","+g+","+b+")"
			}
			function test2()
			{
				clearInterval(t)
			}
		</script>
		
	</body>
</html>
